namespace Delphi.Mimir.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddFinancialStatement : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "fin.eod_financial_statements",
                c => new
                    {
                        fis_id = c.Int(nullable: false, identity: true),
                        fis_sym_id = c.Int(nullable: false),
                        fis_cat_id = c.Int(nullable: false),
                        fis_dt = c.DateTime(nullable: false),
                        fis_is_tot_rev = c.Long(),
                        fis_is_cogs = c.Long(),
                        fis_is_rnd = c.Long(),
                        fis_is_sga = c.Long(),
                        fis_is_nrec_op_ex = c.Long(),
                        fis_is_other_op_ex = c.Long(),
                        fis_is_tot_other_inc_ex_net = c.Long(),
                        fis_is_int_ex_net = c.Long(),
                        fis_is_inc_tax_ex = c.Long(),
                        fis_is_min_int = c.Long(),
                        fis_is_disc_ops = c.Long(),
                        fis_is_extra = c.Long(),
                        fis_is_acct_chg = c.Long(),
                        fis_is_other_nrec = c.Long(),
                        fis_is_pref_other_adj = c.Long(),
                        fis_is_quality_fg = c.Boolean(),
                        fis_is_quality_adj = c.Long(),
                        fis_bs_ca_cash_eqiv = c.Long(),
                        fis_bs_ca_st_inv = c.Long(),
                        fis_bs_ca_rec_net = c.Long(),
                        fis_bs_ca_invtry = c.Long(),
                        fis_bs_ca_other = c.Long(),
                        fis_bs_nca_lt_inv = c.Long(),
                        fis_bs_nca_ppe = c.Long(),
                        fis_bs_nca_gwill = c.Long(),
                        fis_bs_nca_intang_asst = c.Long(),
                        fis_bs_nca_accum_amort = c.Long(),
                        fis_bs_nca_other = c.Long(),
                        fis_bs_nca_dfrd_lt_asst_chrg = c.Long(),
                        fis_bs_cl_payb_net = c.Long(),
                        fis_bs_cl_st_curr_lt_debt = c.Long(),
                        fis_bs_cl_other = c.Long(),
                        fis_bs_ncl_lt_debt = c.Long(),
                        fis_bs_ncl_other = c.Long(),
                        fis_bs_ncl_dfrd_lt_liab_chrg = c.Long(),
                        fis_bs_ncl_min_int = c.Long(),
                        fis_bs_ncl_neg_gwill = c.Long(),
                        fis_bs_eq_st_opt_wrnt = c.Long(),
                        fis_bs_eq_redeem_prfd_st = c.Long(),
                        fis_bs_eq_prfd_st = c.Long(),
                        fis_bs_eq_comn_st = c.Long(),
                        fis_bs_eq_ret_earn = c.Long(),
                        fis_bs_eq_try_st = c.Long(),
                        fis_bs_eq_cap_splus = c.Long(),
                        fis_bs_eq_other = c.Long(),
                        fis_bs_tng_asst_net = c.Long(),
                        fis_cf_op_depr = c.Long(),
                        fis_cf_op_ni_adj = c.Long(),
                        fis_cf_op_rec_chg = c.Long(),
                        fis_cf_op_liab_chg = c.Long(),
                        fis_cf_op_invtry_chg = c.Long(),
                        fis_cf_op_other_chg = c.Long(),
                        fis_cf_inv_cap_ex = c.Long(),
                        fis_cf_inv = c.Long(),
                        fis_cf_inv_other = c.Long(),
                        fis_cf_fin_div = c.Long(),
                        fis_cf_fin_sale_purch_st = c.Long(),
                        fis_cf_fin_borrow_net = c.Long(),
                        fis_cf_fin_other = c.Long(),
                        fis_cf_fx_chg = c.Long(),
                        fis_cf_cash_eqiv_chg = c.Long(),
                    })
                .PrimaryKey(t => t.fis_id)
                .ForeignKey("fin.com_categories", t => t.fis_cat_id, cascadeDelete: true)
                .ForeignKey("fin.eod_symbols", t => t.fis_sym_id, cascadeDelete: true)
                .Index(t => new { t.fis_sym_id, t.fis_dt, t.fis_cat_id }, unique: true, name: "IX_FIS");
            
        }
        
        public override void Down()
        {
            DropForeignKey("fin.eod_financial_statements", "fis_sym_id", "fin.eod_symbols");
            DropForeignKey("fin.eod_financial_statements", "fis_cat_id", "fin.com_categories");
            DropIndex("fin.eod_financial_statements", "IX_FIS");
            DropTable("fin.eod_financial_statements");
        }
    }
}
